//
//  MFAppDelegate.m
//  MFZSDK
//
//  Created by RJPan on 05/17/2024.
//  Copyright (c) 2024 RJPan. All rights reserved.
//

#import "MFAppDelegate.h"
#import <MFZSDK/MFSDKConfig.h>
#import <MFZSDK/MFSDKManager.h>
#import <AppsFlyerLib/AppsFlyerLib.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <UserNotifications/UserNotifications.h>//iOS 10及之上推送支持库

@interface MFAppDelegate ()<UNUserNotificationCenterDelegate>

@property (nonatomic, strong) MFSDKManager *manager;

@end

@implementation MFAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    
    //初始化SDK
    MFSDKConfig *config = [MFSDKConfig shareManager];
    config.appleId = @"1544737413";//MFSDK提供的App Store的AppleID(必须参数)
    config.appId = @"1100";//MFSDK平台提供的MF平台的appid(必须参数)
    /**
     设置环境(必须参数)
     MFGAMEENV_HK:港澳台环境
     MFGAMEENV_CHESS:棋牌环境
     MFGAMEENV_TW:台湾审核环境
     MFGAMEENV_KO:韩国环境
     MFGAMEENV_WEST:欧美环境
     */
    config.setMFENV = MFGAMEENV_DEBUG;
    config.currencyType = @"USD";//交易货币类型，默认美元
    config.fbPageId = @"109901638145293";//接入fb与Messenger连接功能所必须的参数
    _manager = [[MFSDKManager alloc] init];
    [_manager MFSDKApplication:application didFinishLaunchingWithOptions:launchOptions mfConfig:config];
    
    NSLog(@"fbsdkVersion:%@", [[FBSDKSettings sharedSettings] sdkVersion]);//fbsdkVersion：16.2.1
    NSLog(@"AF sdk version:%@", [AppsFlyerLib shared].getSDKVersion);//AF sdk version:6.12.3
    
    return YES;
}

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
            options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
    //BOOL handled = [MFSDKManager mfApplication:application openURL:url options:options];//若下一句fb原生方法报错，可调用此行
    BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application
                                                                  openURL:url
                                                        sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey]
                                                               annotation:options[UIApplicationOpenURLOptionsAnnotationKey]
                    ];
    // Add any custom logic here.
    return handled;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
